package com.jjyd.crlp.controller;

import com.jjyd.crlp.model.base.ResultModel;
import com.jjyd.crlp.model.dto.register.RegisterLoginDto;
import com.jjyd.crlp.services.RegisterService;
import com.jjyd.crlp.util.encryption.MD5Util;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户注册
 */
@RestController
@RequestMapping("/register")
@Api(description = "用户注册")
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    @PostMapping("")
    @ApiOperation(value = "用户注册")
    public ResultModel<Integer> register(RegisterLoginDto registerLoginDto) {
        String md5 = MD5Util.changeMD5(registerLoginDto.getPassword());
        registerLoginDto.setPassword(md5);
        Integer register = registerService.register(registerLoginDto);
        return new ResultModel<>(register);
    }


}
